package wxapp

import (
    "fmt"
	"wxsdk/wxpay/core"
	//. "wxsdk/wxpay"
	//"github.com/astaxie/beego"
)

type CertTestRequest struct {
	MchId           string   `xml:"mch_id"`                //商户号
	NonceStr        string   `xml:"nonce_str"`             //随机字符串
	Sign            string   `xml:"sign"`                  //签名
}

type CertTestResponse struct {
	ReturnCode     string   `xml:"return_code"`
	ReturnMsg      string   `xml:"return_msg,omitempty"`
	MchId          string   `xml:"mch_id,omitempty"`           // 商户号
	SandboxSignkey string   `xml:"sandbox_signkey,omitempty"`  //
}

//
func  CertTest(mchId,appSecret string) (CertTestResponse,error){
	client := core.GetWxPayClient("",mchId,appSecret,nil)
	var rsp CertTestResponse
	var req = new(CertTestRequest)
	serverUrl := fmt.Sprintf("https://apitest.mch.weixin.qq.com/sandboxnew/pay/getsignkey")
	err := client.Excute(serverUrl, req, &rsp)
    if err != nil {
		return rsp, err
	}
	return rsp, nil
}
